import {Component, Input} from '@angular/core';
import {Router} from "@angular/router";
import Store from "@app/shared/Store";
import T_Array from "@core/Tool/T_Array";
import {ProductRecordComponent} from "../product-record/product-record.component";

@Component({
  selector: 'app-product-detail',
  standalone: true,
  imports: [
    ProductRecordComponent
  ],
  templateUrl: './product-detail.component.html',
  styleUrl: './product-detail.component.css'
})
export class ProductDetailComponent {
  product: Product|undefined;
  private router: Router;

  constructor(router: Router) {
    this.router = router;
  }

  ngOnInit() {
    let urls:T_Array<string> = (<T_Array<string>>this.router.url.split("/")).removeEmpty as T_Array<string>;
    this.product = Store.products.find(product => product.id.toString() === urls.last) as Product;
  }
}
